package projeto.tcc.ifrn.central.janine.model;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

@Entity
public class ItemPedido implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5325748006963560097L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	@ManyToOne
	@JoinColumn(nullable = false)
	private Ingresso ingresso = null;
	private BigDecimal precoUnitario;
	private BigDecimal precoTotal;

	private int qtd = 0;

	public int getQtd() {
		return qtd;
	}

	public void setQtd(int qtd) {
		this.qtd = qtd;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Ingresso getIngresso() {
		return ingresso;
	}

	public void setIngresso(Ingresso ingresso) {
		this.ingresso = ingresso;
	}

	public BigDecimal getPrecoUnitario() {
		return precoUnitario;
	}

	public void setPrecoUnitario(BigDecimal precoUnitario) {
		this.precoUnitario = precoUnitario;
	}

	public BigDecimal getPrecoTotal() {
		return precoTotal;
	}

	public void setPrecoTotal(BigDecimal precoTotal) {
		this.precoTotal = precoTotal;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		result = prime * result
				+ ((ingresso == null) ? 0 : ingresso.hashCode());
		result = prime * result
				+ ((precoTotal == null) ? 0 : precoTotal.hashCode());
		result = prime * result
				+ ((precoUnitario == null) ? 0 : precoUnitario.hashCode());
		result = prime * result + qtd;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ItemPedido other = (ItemPedido) obj;
		if (id != other.id)
			return false;
		if (ingresso == null) {
			if (other.ingresso != null)
				return false;
		} else if (!ingresso.equals(other.ingresso))
			return false;
		if (precoTotal == null) {
			if (other.precoTotal != null)
				return false;
		} else if (!precoTotal.equals(other.precoTotal))
			return false;
		if (precoUnitario == null) {
			if (other.precoUnitario != null)
				return false;
		} else if (!precoUnitario.equals(other.precoUnitario))
			return false;
		if (qtd != other.qtd)
			return false;
		return true;
	}

}
